/* eslint-disable */
import Vue from 'vue';
$.i18n = function(key) {
    var i18nKey = "i18n_" + _locale + "_" + key;
    try {
        var msg = "";
        var appId = getCtpTop().APPID;
        if (window.localStorage) {
            var data = null;
            /*data = window._i18n_ = window.localStorage.getItem("i18n_DATA");*/
            if (!window._i18n_) {
                window._i18n_ = window.localStorage.getItem("i18n_DATA");
                data = window._i18n_;
            } else {
                data = window._i18n_;
            }
            if (data == null) {
                var _url = typeof (_staticSuffix) === "string" ? _ctxPath + "/i18n_init_" + _locale + ".js" + _staticSuffix : _ctxPath + "/i18n_init_" + _locale + ".js?timestamp=" + new Date().getTime();
                $.ajax({
                    url: _url,
                    async: false,
                    beforeSend: CsrfGuard.beforeAjaxSend,
                    dataType: "script"
                });
                data = window.localStorage.getItem("i18n_DATA")
            }
            var k = "|_" + key + ",";
            var firstIndex = data.indexOf(k);
            if (firstIndex > -1) {
                var lastIndex = data.indexOf("_|", firstIndex);
                msg = data.substring(firstIndex + k.length, lastIndex)
            }
            data = null
        } else {
            if (!CTPLang) {
                var _url = typeof (_staticSuffix) === "string" ? _ctxPath + "/i18n_" + _locale + ".js" + _staticSuffix : _ctxPath + "/i18n_" + _locale + ".js?" + new Date().getTime();
                $.ajax({
                    url: _url,
                    async: false,
                    beforeSend: CsrfGuard.beforeAjaxSend,
                    dataType: "script"
                })
            }
            var lang = CTPLang[_locale];
            if (!lang) {
                return key
            }
            var msg = lang[key + _editionI18nSuffix.toUpperCase()];
            if (!msg) {
                msg = lang[key + _editionI18nSuffix.toLowerCase()]
            }
            if (!msg) {
                msg = lang[key]
            }
        }
        if (msg && arguments.length > 1) {
            var messageRegEx_0 = /\{0\}/g;
            var messageRegEx_1 = /\{1\}/g;
            var messageRegEx_2 = /\{2\}/g;
            var messageRegEx_3 = /\{3\}/g;
            var messageRegEx_4 = /\{4\}/g;
            var messageRegEx_5 = /\{5\}/g;
            var messageRegEx_6 = /\{6\}/g;
            var messageRegEx_7 = /\{7\}/g;
            var messageRegEx_8 = /\{8\}/g;
            var messageRegEx_9 = /\{9\}/g;
            var messageRegEx_10 = /\{10\}/g;
            var messageRegEx_11 = /\{11\}/g;
            var messageRegEx_12 = /\{12\}/g;
            var messageRegEx_13 = /\{13\}/g;
            var messageRegEx_14 = /\{14\}/g;
            var messageRegEx_15 = /\{15\}/g;
            for (var i = 0; i < arguments.length - 1; i++) {
                var regEx = eval("messageRegEx_" + i);
                var repMe = "" + arguments[i + 1];
                if (repMe.indexOf("$_") != -1) {
                    repMe = repMe.replace("$_", "$$_")
                }
                msg = msg.replace(regEx, repMe)
            }
        }
        if (msg == undefined || msg == null || msg == "") {
            msg = key
        }
        return msg
    } catch (e) {}
    return ""
}
let t = null;
if ((window.ctpTop || window.top).$ && (window.ctpTop || window.top).$.i18n) t = (window.ctpTop || window.top).$.i18n; else {
    t = function e(t) {
        return t ? t.$ && t.$.i18n ? t.$.i18n : t != t.parent ? e(t.parent) : null : null;
    }(window);
};
window.$i18n = function () {
    if (t) {
        if (!arguments[0]) return;
        const e = arguments[0];
        if ('string' == typeof e) return t.apply(null, arguments);
        const n = t.apply(this, [e.key1]);
        return n && n != e.key1 ? n : t.apply(null, [e.key2]);
    }
};
Vue.prototype.$i18n = function () {
    if (t) {
        if (!arguments[0]) return;
        const e = arguments[0];
        if ('string' == typeof e) return t.apply(null, arguments);
        const n = t.apply(this, [e.key1]);
        return n && n != e.key1 ? n : t.apply(null, [e.key2]);
    }
};
/*Vue.prototype.$i18n = function () {
    return '瞅瞅啥呢';
};*/
